package com.hjxr.quota.datasource.domain;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

/**
 * 字段别名表实体类(quota_colname_alias )
 *
 * @author sun
 * @version v1.0
 * @since 2020-08-16
 */
@Data
@ApiModel
@TableName("quota_colname_alias")
@KeySequence(value = "seq_quota_colname_alias", clazz = Integer.class)
public class ColnameAlias extends Model<ColnameAlias> {

    /**
     * 自增主键
     */
    @TableId(value = "id", type = IdType.INPUT)
    @ApiModelProperty(value = "自增主键")
    private Integer id;

    /**
     * 数据表别名表id
     */
    @ApiModelProperty(value = "数据表别名表id")
    private Integer tablenameAliasId;

    /**
     * 字段名称
     */
    @ApiModelProperty(value = "字段名称")
    private String columnName;

    /**
     * 字段名称
     */
    @ApiModelProperty(value = "数据类型")
    private String dataType;

    /**
     *字段说明
     */
    @ApiModelProperty(value = "字段说明")
    private String columnDesc;

    /**
     *字段别名
     */
    @ApiModelProperty(value = "字段别名")
    private String columnAlias;

    /**
     *是否指标，1:是指标；0:不是指标
     */
    @ApiModelProperty(value = "是否指标，1:是指标；0:不是指标")
    private String isquota;

    /**
     *是否维度，1:是维度；0不是维度
     */
    @ApiModelProperty(value = "是否维度，1:是维度；0不是维度")
    private String isdimension;

    /**
     *更新人
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "更新人", hidden = true)
    private String updateBy;

    /**
     *
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JSONField(format = "yyyy/MM/dd")
    @ApiModelProperty(value = "更新时间", hidden = true)
    private Date updateDate;

    public String getName() {
        return (this.columnAlias == null || "".equals(this.columnAlias)) ? this.columnName : this.columnAlias;
    }
}
